<template>
	<view class="main">
		<view class="cont">
			<image class="bg" src="../../static/image/result-bg.png" mode=""></image>
			<image class="icon" src="../../static/image/result-success.png" mode=""></image>
			<view class="blue">
				审核成功!
			</view>
			<view class="tips">
				恭喜您，您的信息审核已通过！
			</view>
			<template v-if="isShow">
				<navigator v-if="!signContract" class="btn" hover-class="none"
					:url="'./laborContract?userId=' + userId + '&signContract=' + signContract">
					签署劳动合同
				</navigator>
				<view @click="findByUserIdContract(userId)" v-else class="btn">查看劳动合同</view>
				<navigator v-if="!signNotification" class="btn" hover-class="none"
					:url="'./notification?userId=' + userId + '&signNotification=' + signNotification">签署进场告知书
				</navigator>
				<view @click="findByUserIdNotification(userId)" v-else class="btn">查看进场告知书</view>
			</template>
		</view>
	</view>
</template>

<script>
	import config from '@/common/config.js';
	export default {
		data() {
			return {
				isShow: false,
				userId: null,
				signContract: null, //是否签署合同
				signNotification: null, //是否签署进场通知书
				imgUrl: ''
			}
		},
		onLoad(option) {
			if (option.type == 'self' && option.role == 3) {
				this.isShow = true;
			} else {
				this.isShow = false;
			}
			this.userId = option.id;
			this.imgUrl = config.imgUrl + '/';
		},
		onShow() {
			this.userFind(this.userId);
		},
		methods: {
			// 查看劳动合同-获取劳务人员用工合同
			findByUserIdContract(userId) {
				this.$u.api.findByUserIdContract({
					userId: userId
				}).then(res => {
					console.log('获取劳务人员用工合同', res.data);
					uni.downloadFile({
						url: this.imgUrl + res.data.contarctImage,
						success: res => {
							uni.openDocument({
								filePath: res.tempFilePath,
								success: (res) => {
									console.log(res, '文件打开成功');
								}
							})
						}
					})
				})
			},
			// 查看进场告知书-获取劳务人员进场告知书
			findByUserIdNotification(userId) {
				this.$u.api.findByUserIdNotification({
					userId: userId
				}).then(res => {
					console.log('获取劳务人员进场告知书', res.data);
					uni.downloadFile({
						url: this.imgUrl + res.data.informImage,
						// url:'https://ikeway.oss-cn-chengdu.aliyuncs.com/file/emergency/20211119164220P4a3e.pdf',
						success: res => {
							uni.openDocument({
								filePath: res.tempFilePath,
								success: (res) => {
									console.log(res, '文件打开成功');
								}
							})
						}
					})
				})
			},
			userFind(id) {
				this.$u.api.userFind({
					id: id
				}).then(res => {
					console.log(res.data);
					this.signContract = res.data.userBaseInfo.signContract;
					this.signNotification = res.data.userBaseInfo.signNotification;
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		height: 100vh;
		background-color: #30A1FF;
		padding-top: 192rpx;

		.cont {
			height: calc(100vh - 192rpx);
			position: relative;
			text-align: center;

			.bg {
				position: absolute;
				left: 0;
				top: 0;
				z-index: 5;
				width: 100%;
				height: calc(100vh - 192rpx);
			}

			.icon {
				width: 200rpx;
				height: 200rpx;
				margin-top: 232rpx;
				position: relative;
				z-index: 10;
			}

			.blue {
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #2A86EF;
				margin-top: 36rpx;
				position: relative;
				z-index: 10;
			}

			.tips {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #828282;
				margin-top: 24rpx;
				position: relative;
				z-index: 10;
			}

			.btn {
				width: 560rpx;
				height: 80rpx;
				background: #2A86EF;
				border-radius: 40rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 80rpx;
				color: #FFFFFF;
				text-align: center;
				margin: 0 auto;
				margin-top: 90rpx;
				position: relative;
				z-index: 10;
			}
		}
	}
</style>
